#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
int dominantIndex(int* nums, int numsSize) {
    int i = 0;
    int FirstMax = nums[0];
    int FirstMaxPos = 0;
    int SecondMax = nums[1];
    if (nums[0] < nums[1])
    {
        FirstMax = nums[1];
        SecondMax = nums[0];
        FirstMaxPos = 1;
    }
    for (i = 2; i < numsSize; i++)
    {
        if (nums[i] > FirstMax)
        {
            SecondMax = FirstMax;
            FirstMax = nums[i];
            FirstMaxPos = i;
        

        }
        else if (nums[i]<FirstMax && nums[i]>SecondMax)
        {
            SecondMax = nums[i];
        }
    }
    if (FirstMax >= (SecondMax * 2))
    {
        return  FirstMaxPos;
    }
    else
    {
        return -1;
    }


}


int main()
{
    int arr[] = { 0,0,0,1 };
    int ret = dominantIndex(arr, 4);
    printf("%d", ret);
    return 0;
}